<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     pagizer
 * @subpackage  website
 */

class m_website_documents_Html extends m_website_documents_HtmlBase
{

	private static $instances;
	
	/**
	 * @return m_website_documents_Html
	 */
	public static function createNew()
	{
		return new self();
	}
	
	/**
	 * @return m_website_documents_Html
	 */
	public static function getInstanceByUniqueId($id, $lang = null)
	{
		if(is_null($lang)) $lang = f_core_Context::getInstance()->getLang();
		
		if(!isset(self::$instances[$lang][$id]))
		{
			$cache = f_core_Cache::getInstance();
			
			$key = $cache->getDocumentCacheKey($id, $lang);
			
			if($cache->hasCache($key))
			{
				return $cache->getCacheContent($key);
			}
			
			self::$instances[$lang][$id] = new self($id, $lang);
			
			$cache->putInCache($key, self::$instances[$lang][$id]);
			
			return self::$instances[$lang][$id];			
		}

		return self::$instances[$lang][$id];
	}
	
	// Your code here...
}